var a = getApp();

Page({
    data: {
        list: [],
        current_page: 1,
        last_page: 1,
        aid: "",
        show_type: 0,
        axis: {}
    },
    onLoad: function(t) {
        if (t.scene) {
            var e = decodeURIComponent(t.scene);
            if (e) {
                var i = [];
                i = e.split("&");
                for (var r = 0; r < i.length; r++) {
                    var s;
                    "m" == (s = i[r].split("="))[0] ? a._setMid(s[1]) : "id" == s[0] && this.setData({
                        aid: s[1]
                    });
                }
            }
        }
        t.id && this.setData({
            aid: t.id
        }), this.getData();
    },
    change: function(t) {
        var e = this;
        this.setData({
            show_type: t.detail
        }), a._getNetWork({
            url: a.getNetAddresss("plugin.time-axis.frontend.controllers.axis.eventList"),
            data: {
                show_type: this.data.show_type,
                aid: this.data.aid
            },
            success: function(t) {
                var i = t.data.data;
                if (0 == t.data.result) return a.tips(t.data.msg);
                i.list.data.forEach(function(a) {
                    a.label_arr && 0 !== a.label_arr.length && (a.label_color = e.createGroups(a.label_arr, 4), 
                    a.label_color = e.feat_color(a.label_color));
                }), e.setData({
                    list: i.list.data,
                    current_page: i.list.current_page,
                    last_page: i.list.last_page
                });
            }
        });
    },
    link: function(a) {
        var t = a.currentTarget.dataset.datas;
        1 == t.mini_link_type ? t.mini_link_path && wx.navigateTo({
            url: "".concat(t.mini_link_path)
        }) : 2 == t.mini_link_type && t.out_mini_link_path && t.out_mini_app_id && wx.navigateToMiniProgram({
            appId: t.out_mini_app_id,
            path: t.out_mini_link_path
        });
    },
    getData: function() {
        var t = this;
        a._getNetWork({
            url: a.getNetAddresss("plugin.time-axis.frontend.controllers.axis.eventList"),
            data: {
                aid: this.data.aid
            },
            success: function(e) {
                var i = e.data.data;
                if (0 == e.data.result) return a.tips(e.data.msg);
                i.list.data.forEach(function(a) {
                    a.label_arr && 0 !== a.label_arr.length && (a.label_color = t.createGroups(a.label_arr, 4), 
                    a.label_color = t.feat_color(a.label_color));
                }), t.setData({
                    axis: i.axis,
                    show_type: i.axis.show_type,
                    list: i.list.data,
                    current_page: i.list.current_page,
                    last_page: i.list.last_page
                });
            }
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        var t = this;
        if (!(this.data.current_page >= this.data.last_page)) {
            var e = this.data.current_page + 1;
            a._getNetWork({
                url: a.getNetAddresss("plugin.time-axis.frontend.controllers.axis.eventList"),
                data: {
                    page: e,
                    aid: this.data.aid,
                    show_type: this.data.show_type
                },
                success: function(e) {
                    var i = e.data.data;
                    if (0 == e.data.result) return a.tips(e.data.msg);
                    i.list.data.forEach(function(a) {
                        a.label_arr && 0 !== a.label_arr.length && (a.label_color = t.createGroups(a.label_arr, 4), 
                        a.label_color = t.feat_color(a.label_color));
                    }), t.setData({
                        list: t.data.list.concat(i.list.data),
                        current_page: i.list.current_page,
                        last_page: i.list.last_page
                    });
                }
            });
        }
    },
    createGroups: function(a, t) {
        for (var e = 0, i = []; e < a.length; ) i.push(a.slice(e, e += t));
        return i;
    },
    feat_color: function(a) {
        var t = [], e = [ "#13C7A7", "#FCA814", "#FC6614", "#1481FC" ];
        a.forEach(function(a, i) {
            t[i] = [], a.forEach(function(a, r) {
                t[i].push({
                    color: e[r],
                    label: a
                });
            });
        });
        var i = [];
        return t.forEach(function(a) {
            a.forEach(function(a) {
                i.push(a);
            });
        }), i;
    },
    onShareAppMessage: function() {}
});